import java.util.ArrayList;
import java.util.List;

public class MinimumNumbers {

    public static void main(String[] args) {
        MinimumNumbers minimumNumbers = new MinimumNumbers();
        System.out.println(minimumNumbers.minimumNumbers(20, 1));
    }

    public int minimumNumbers(int num, int k) {
        if (num == 0) return 0;
        boolean flag = true;
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            if ((k * i) % 10 == num % 10) {
                flag = false;
                list.add(i);
            }
        }
        int ans = Integer.MAX_VALUE;
        if (flag || k > num) return -1;
        for (int i = 0; i < list.size(); i++) {
            int index = list.get(i);
            if ((k * index) <= num) {
               ans = Math.min(ans, index);
            }
        }
        return ans == Integer.MAX_VALUE ? -1 : ans;
    }
}
